import time

def bubble_sort(nums):
    a = len(nums) - 1
    for s in range(a):
        swapped = False
        for z in range(a - s):
            if nums[z] > nums[z + 1]:
                nums[z], nums[z + 1] = nums[z + 1], nums[z]
                swapped = True

def read_to_list(filename):
    file = open(filename,)
    g = file.readlines()
    return [int(x) for x in g]

filenames = ["m1_sorted.txt", "m2_reverse.txt", "m3_shuffle.txt"]

for filename in filenames:
    m = read_to_list(filename)
    t_s = time.time()
    bubble_sort(m)
    t_f = time.time()
    print(filename.split('.')[0], round((t_f - t_s) * 1000), "milliseconds")
